<template>
  <div class="zw-search">
    <el-icon style="margin: 0px 16px; cursor: pointer;" @click="navStore.toggleCollapsed">
      <component :is="navStore.isCollapsed ? Expand : Fold"></component>
    </el-icon>
    <slot name="base"></slot>
    <el-button style="margin-left: 12px;" size="small" type="primary" @click="query" :icon="Search"
      title="查询"></el-button>
    <el-button v-if="props.showAdvanceQuery" size="small" type="primary" @click="onShowAdvanceQuery" title="更多条件"
      :icon="Filter"></el-button>
    <slot name="append"></slot>
    <div v-show="showAdvance" class="advance">
      <div class="advance-wrapper">
        <div class="advance-wrapper-title">更多查询条件</div>
        <div class="advance-wrapper-body">
          <slot name="advance"></slot>
        </div>
        <div class="advance-wrapper-button-group">
          <el-button type="primary" @click="query">查询</el-button>
          <el-button @click="showAdvance = false">关闭</el-button>
        </div>
      </div>
    </div>
  </div>
</template>
<script lang="ts" setup>
import { useNavStore } from '@/stores/LeftNavStore';
import { ref } from 'vue';
import {
  Expand, Fold, Filter, Search
  ,
} from '@element-plus/icons-vue';

const props = defineProps<{
  showAdvanceQuery: boolean
}>();

const emits = defineEmits(["onQuery"]);
const query = () => {
  emits("onQuery");
  showAdvance.value = false;
}
const showAdvance = ref(false);
const onShowAdvanceQuery = () => {
  showAdvance.value = true;
}

const navStore = useNavStore();
</script>
<style lang="scss" scope>
.zw-search {
  width: 100%;
  height: 100%;
  // padding: 0px 20px;
  display: flex;
  align-items: center;
}

.advance {
  width: 100vw;
  height: 100vh;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba($color: #000, $alpha: 0.5);
  z-index: 19921212;
  display: flex;
  justify-content: center;
  align-items: center;

  &-wrapper {
    width: 640px;
    // height: 480px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background-color: #fff;
    display: flex;
    flex-direction: column;
    border-radius: 5px;

    &-title {
      width: 100%;
      height: 48px;
      line-height: 48px;
      font-weight: 600;
      border-bottom: 1px solid v.$border-color;
      padding-left: 12px;
    }

    &-button-group {
      height: 48px;
      border-top: 1px solid v.$border-color;
      display: flex;
      justify-content: center;
      align-items: center;
      width: 100%;
    }

    &-body {
      padding: 12px;
      flex: 1;
    }
  }
}
</style>
